<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var a = '2'
    console.log(typeof a)
    a = Number(a)
    console.log(typeof a)

    var num = '3.444'
    num = Number(num)
    console.log(num)

    var num1 = 3.141592657
    // 把小数保留4位，四舍五入
    num1 = num1.toFixed(4)
    console.log(num1)

  </script>
</body>
</html>